function init_dropdown(){
    if(!$('ul').length){
        return;
    }

    $('ul li').hover(function(){
        $(this).find('ul').fadeIn(1000);
        $(this).find('ul li ul').hide();
    },
    function(){
        $(this).find('ul').hide();
    })
}
$(document).ready(function() {
    init_dropdown();

    $('input:text, input:password, select, textarea').addClass('ui-widget ui-widget-content');
    $( "input:submit,input:button").button();

    $('a.add').button({
        icons: {
            primary: "ui-icon-plus"
        }
    });

    $('a.edit').button({
        icons: {
            primary: "ui-icon-pencil"
        }
    });

    $('a.delete').button({
        icons: {
            primary: "ui-icon-trash"
        }
    });

    $('.hledej').button({
        icons: {
            primary: "ui-icon-search"
        }
    });

    $('.message').click(function() {
        $(this).fadeOut('10000');
    });

    $('a[data-confirm], button[data-confirm], input[data-confirm]').click(function (e) {
        if (!confirm($(this).attr('data-confirm'))) {
            e.preventDefault();
            e.stopImmediatePropagation();
            return false;
        }
    });

    $( "#dialog-form" ).dialog({
        autoOpen: false,
        height: 250,
        width: 300,
        modal: true,
        close: function() {
        }
    });

    $( ".delete-user" ).click(function() {
        var id = $(this).attr('data-id');
        $('#id').val(id);
        $( "#dialog-form" ).dialog( "open" );
    });

    $( ".delete-role" ).click(function() {
        var id = $(this).attr('data-id');
        $('#id').val(id);
        $( "#dialog-form" ).dialog( "open" );
    });
});

